package com.woniu.web.service.impl;

import com.woniu.common.entity.TbJpUserPart;

import com.woniu.common.entity.TbJpUserPartExample;
import com.woniu.web.mapper.TbJpUserPartDao;
import com.woniu.web.service.TbJpUserPartService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class TbJpUserPartServiceImpl implements TbJpUserPartService {
    @Resource
    TbJpUserPartDao userPartDao;
    @Override
    public List<TbJpUserPart> findAll() {
        return userPartDao.selectByExample(null) ;
    }

    @Override
    public TbJpUserPart findByUname(String uname) {
        try {
            TbJpUserPartExample partExample=new TbJpUserPartExample();
            partExample.createCriteria().andPhoneEqualTo(Long.valueOf(uname));
            List<TbJpUserPart> tbJpUserParts = userPartDao.selectByExample(partExample);
            if (tbJpUserParts.size()==1){
                return tbJpUserParts.get(0);
            }
        } catch (NumberFormatException e) {
            return null;
        }
        return null;
    }
}
